package com.sx.admin.controller.plat;

import com.sx.admin.controller.BaseController;
import com.sx.core.model.Operator;
import com.sx.core.mybatis.SessionTemplate;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by lihao on 2017/6/29.
 */
@RequestMapping("plat/optor")
@Controller
public class OperatorPagesController extends BaseController {

    @Autowired
    SessionTemplate sessionTemplate;
    @RequestMapping("edit")
    public String edit(String code,Model model){
        if(StringUtils.isEmpty(code)){
            return "plat/optor/edit";
        }
        Operator operator=sessionTemplate.get(Operator.class,code);
        model.addAttribute("operator",operator);
        return "plat/optor/edit";
    }

    @RequestMapping("optrators")
//    @RequiresPermissions("info_optor_optrators")
    public String optrators(Model model){
        return "plat/optor/optrators";
    }

    @RequestMapping("optratorsAdd")
    public String optratorsAdd(String code,Model model){
        if(StringUtils.isNotBlank(code)){
            Operator operator=sessionTemplate.get(Operator.class,code);
            model.addAttribute("command",operator);
        }
        return "plat/optor/optratorsAdd";
    }

}
